/* 
 * This file is part of Grobil.
 * 
 * Grobil is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Grobil is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Grobil.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.grobil.core.impl;

import javax.swing.event.EventListenerList;

import org.grobil.core.Card;
import org.grobil.core.CardPile;
import org.grobil.core.Game;
import org.grobil.core.Player;
import org.grobil.core.event.GameListener;
import org.grobil.util.AbstractBean;

/**
 * @author Olivier Grgoire
 * 
 */
public class GameImpl
        extends AbstractBean
        implements Game {
	
	private final EventListenerList	eventListeners;
	
	public GameImpl (EventListenerList eventListeners) {
		if (eventListeners == null)
			throw new NullPointerException("eventListeners is null");
		this.eventListeners = eventListeners;
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see org.grobil.core.Game#addGameListener(org.grobil.core.event.GameListener)
	 */
	@Override
	public void addGameListener(GameListener listener) {
		if (listener == null) {
			return;
		}
		this.eventListeners.add(GameListener.class, listener);
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see org.grobil.core.Game#addPlayer(org.grobil.core.Player)
	 */
	@Override
	public boolean addPlayer(Player player) throws IllegalStateException,
	        NullPointerException {
		// TODO Auto-generated method stub
		return false;
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see org.grobil.core.Game#dealHand(org.grobil.core.Player)
	 */
	@Override
	public void dealHand(Player player) {
		player.getHand().add(this.getDungeonCards().draw(2));
		player.getHand().add(this.getTreasureCards().draw(2));
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see org.grobil.core.Game#getCurrentPlayer()
	 */
	@Override
	public Player getCurrentPlayer() {
		// TODO Auto-generated method stub
		return null;
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see org.grobil.core.Game#getDungeonCards()
	 */
	@Override
	public CardPile getDungeonCards() {
		// TODO Auto-generated method stub
		return null;
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see org.grobil.core.Game#getGameListeners()
	 */
	@Override
	public GameListener[] getGameListeners() {
		return this.eventListeners.getListeners(GameListener.class);
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see org.grobil.core.Game#getMaximumPlayers()
	 */
	@Override
	public int getMaximumPlayers() {
		// TODO Auto-generated method stub
		return 0;
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see org.grobil.core.Game#getName()
	 */
	@Override
	public String getName() {
		// TODO Auto-generated method stub
		return null;
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see org.grobil.core.Game#getTreasureCards()
	 */
	@Override
	public CardPile getTreasureCards() {
		// TODO Auto-generated method stub
		return null;
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see org.grobil.core.Game#initializeCombat(org.grobil.core.Player,
	 *      org.grobil.core.Card)
	 */
	@Override
	public void initializeCombat(Player player, Card card) {
		// TODO Auto-generated method stub
		
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see org.grobil.core.Game#removeGameListener(org.grobil.core.event.GameListener)
	 */
	@Override
	public void removeGameListener(GameListener listener) {
		if (listener == null) {
			return;
		}
		this.eventListeners.remove(GameListener.class, listener);
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see org.grobil.core.Game#removePlayer(org.grobil.core.Player)
	 */
	@Override
	public boolean removePlayer(Player player) throws IllegalStateException,
	        NullPointerException {
		// TODO Auto-generated method stub
		return false;
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see org.grobil.core.Game#resurrectDeadPlayers()
	 */
	@Override
	public void resurrectDeadPlayers() {
		// TODO Auto-generated method stub
		
	}
}
